<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../../../component/layui/css/layui.css">
    <script src="../../../component/layui/layui.js"></script>
</head>
<body style="margin: 10px;background-color: whitesmoke;">
	<div class="layui-card">
		<div class="layui-card-header">
			默认图标
		</div>
		<div class="layui-card-body">
			<div class="layui-form">
			    <div class="layui-form-item">
			        <div class="layui-input-inline">
			            <input type="text" id="iconPicker" lay-filter="iconPicker" class="hide">
			        </div>
			    </div>
			</div>
		</div>
	</div>
	<div class="layui-card">
		<div class="layui-card-header">自定义图标</div>
	    <div class="layui-card-body">
			<div class="layui-form">
				<div class="layui-form-item">
				     <div class="layui-input-inline">
				        <input type="text" id="iconPicker2" value="layui-icon-face-smile-fine" lay-filter="iconPicker2" class="hide">
				    </div>
				</div>
			</div>
		</div>
	</div>
	<div class="layui-card">
		<div class="layui-card-header">JSON 获取</div>
	    <div class="layui-card-body">
			<div class="layui-form">
			<div class="layui-form-item">
			     <div class="layui-input-inline">
			        <input type="text" id="iconPicker4" lay-filter="iconPicker4" class="hide">
			    </div>
			</div>
			</div>
		</div>
	</div>
    <script>
        layui.use(['iconPicker', 'form', 'layer'], function () {
            var iconPicker = layui.iconPicker,
                form = layui.form,
                layer = layui.layer,
                $ = layui.$;
            
            iconPicker.render({
                // 选择器，推荐使用input
                elem: '#iconPicker',
                // 数据类型：fontClass/unicode，推荐使用fontClass
                type: 'fontClass',
                // 是否开启搜索：true/false，默认true
                search: true,
                // 是否开启分页：true/false，默认true
                page: true,
                // 每页显示数量，默认12
                limit: 12,
                // 点击回调
                click: function (data) {
                    console.log(data);
                },
                // 渲染成功后的回调
                success: function(d) {
                    console.log(d);
                }
            });
			
            iconPicker.render({
                // 选择器，推荐使用input
                elem: '#iconPicker2',
                // 数据类型：fontClass/unicode，推荐使用fontClass
                type: 'fontClass',
                // 是否开启搜索：true/false
                search: true,
                // 是否开启分页
                page: true,
                // 每页显示数量，默认12
                limit: 12,
                // 点击回调
                click: function (data) {
                    console.log(data);
                },
                // 渲染成功后的回调
                success: function(d) {
                    console.log(d);
                }
            });
			
            iconPicker.render({
                elem: '#iconPicker3',
                type: 'fontClass',
                search: true,
                page: true,
                limit: 12,
                click: function (data) {
                    console.log(data);
                },
                success: function(d) {
                    console.log(d);
                }
            });

            iconPicker.render({
                elem: '#iconPicker3-2',
                type: 'fontClass',
                search: true,
                page: true,
                limit: 12,
                click: function (data) {
                    console.log(data);
                },
                success: function(d) {
                    console.log(d);
                }
            });

            $('#layer').click(function(){
                layer.open({
                    type: 1,
                    area: ['500px', '400px'],
                    content: $('#layer-modal'),
                    success: function(layero){
                        iconPicker.checkIcon('iconPicker3-2', 'layui-icon-cellphone');
                    }
                });
            });

            $('#btnSubmit3-2').click(function(){
                alert($('#iconPicker3-2').val());
            });
			
            iconPicker.render({
                elem: '#iconPicker4',
                type: 'fontClass'
            });

            $.getJSON("json/example.json",function(result){
                console.log(result);
                var icon = result.data[0].icon;
                console.log(icon);
                iconPicker.checkIcon('iconPicker4', icon);
            });

        });
    </script>
</body>
</html>